package com.ruoyi.system.controller.car4s_controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.car4s_domain.Car4sPartsStockDetail;
import com.ruoyi.system.service.car4s_service.ICar4sPartsStockDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 配件库存明细Controller
 * 
 * @author LK
 * @date 2024-06-29
 */
@RestController
@RequestMapping("/system/car_4s_parts_stock_detail")
public class Car4sPartsStockDetailController extends BaseController
{
    @Autowired
    private ICar4sPartsStockDetailService car4sPartsStockDetailService;

    /**
     * 查询配件库存明细列表
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_parts_stock_detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(Car4sPartsStockDetail car4sPartsStockDetail)
    {
        startPage();
        List<Car4sPartsStockDetail> list = car4sPartsStockDetailService.selectCar4sPartsStockDetailList(car4sPartsStockDetail);
        return getDataTable(list);
    }

    /**
     * 导出配件库存明细列表
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_parts_stock_detail:export')")
    @Log(title = "配件库存明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Car4sPartsStockDetail car4sPartsStockDetail)
    {
        List<Car4sPartsStockDetail> list = car4sPartsStockDetailService.selectCar4sPartsStockDetailList(car4sPartsStockDetail);
        ExcelUtil<Car4sPartsStockDetail> util = new ExcelUtil<Car4sPartsStockDetail>(Car4sPartsStockDetail.class);
        util.exportExcel(response, list, "配件库存明细数据");
    }

    /**
     * 获取配件库存明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_parts_stock_detail:query')")
    @GetMapping(value = "/{partsStockDetailId}")
    public AjaxResult getInfo(@PathVariable("partsStockDetailId") Long partsStockDetailId)
    {
        return success(car4sPartsStockDetailService.selectCar4sPartsStockDetailByPartsStockDetailId(partsStockDetailId));
    }

    /**
     * 新增配件库存明细
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_parts_stock_detail:add')")
    @Log(title = "配件库存明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Car4sPartsStockDetail car4sPartsStockDetail)
    {
        return toAjax(car4sPartsStockDetailService.insertCar4sPartsStockDetail(car4sPartsStockDetail));
    }

    /**
     * 修改配件库存明细
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_parts_stock_detail:edit')")
    @Log(title = "配件库存明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Car4sPartsStockDetail car4sPartsStockDetail)
    {
        return toAjax(car4sPartsStockDetailService.updateCar4sPartsStockDetail(car4sPartsStockDetail));
    }

    /**
     * 删除配件库存明细
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_parts_stock_detail:remove')")
    @Log(title = "配件库存明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{partsStockDetailIds}")
    public AjaxResult remove(@PathVariable Long[] partsStockDetailIds)
    {
        return toAjax(car4sPartsStockDetailService.deleteCar4sPartsStockDetailByPartsStockDetailIds(partsStockDetailIds));
    }
}
